class PostCategory < ActiveRecord::Base
  acts_as_tree :order => "id asc"
  has_many :common_posts
  
  def common_posts_by_community(community)
    @posts = CommonPost.find(:all, :conditions => [ "post_category_id = ? and community_id = ?",self.id, community.id], :order => "replied_at desc")
  end
  
  def common_posts_by_district(district)
    @posts = CommonPost.find(:all, :conditions => [ "post_category_id = ? and district_id = ?",self.id, district.id], :order => "replied_at desc")
  end
  
end
